<%@page import="web.vungsi"%><%@page import="java.sql.*"%><%@page contentType="text/html" pageEncoding="UTF-8"%><%
    String user_id = request.getParameter("uid");
    String post_id = request.getParameter("pid");

    String koneksiURL = "jdbc:mysql://localhost/progin_171_13509024?user=progin&password=progin";
    Connection koneksi = null;
    Statement statement = null;
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    koneksi = DriverManager.getConnection(koneksiURL);
    statement = koneksi.createStatement();


    String igna = "INSERT INTO tbl_dislike(user_id, post_id) VALUES('" + user_id + "' , '" + post_id + "')";
    int predo = statement.executeUpdate(igna);
    if (predo != 0) {
        ResultSet ambilTebel = statement.executeQuery("SELECT dislike_count FROM tbl_post WHERE id=" + post_id);
        ambilTebel.next();
        int dislike_count = ambilTebel.getInt("dislike_count");
        dislike_count++;
        String ubahLike = "UPDATE tbl_post SET dislike_count='" + dislike_count + "' WHERE id=" + post_id;
        int dodo = statement.executeUpdate(ubahLike);

    }
    out.print("bener");
%>